<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="button" value="10" data-counter />
    <input type="button" value="10" />
    <input type="button" value="10" data-counter />
    <input type="button" value="10" />
    <script>
      // 复用（重复使用）
      document.body.addEventListener("click", function (e) {
        const target = e.target;
        // '' 或者 undefined
        const counter = target.dataset.counter;
        if (counter === undefined) {
          return;
        }
        // 只有具备counter特性才会执行
        // console.log(target);
        target.value = Number(target.value) + 1;
        // target.value++;
      });
    </script>
  </body>
</html>
